﻿using AbpEntityFrameworkcore.DbContext;
using AbpToDomain.View;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AbpApplication.Expand
{
    public class QueryDynamic_View_Box
    {

        private readonly MyDbContext context;

        public QueryDynamic_View_Box(MyDbContext context)
        {
            this.context = context;
        }

        public List<View_Box> QueryDynameic(string? BoxCode,int? BoxGridQuantity,
            string? WarehouseLineCode)
        {
            IQueryable<View_Box> view_Boxes = context.viewBox;
            if (!string.IsNullOrEmpty(BoxCode))
            {
                view_Boxes = view_Boxes.Where(b => b.BoxCode.Contains(BoxCode));
            }
            if (!string.IsNullOrEmpty(BoxGridQuantity.ToString()))
            {
                view_Boxes = view_Boxes.Where(b => b.BoxGridQuantity==BoxGridQuantity);
            }
            if (!string.IsNullOrEmpty(WarehouseLineCode))
            {
                view_Boxes = view_Boxes.Where(b => b.WarehouseLineCode.Contains(WarehouseLineCode));
            }
          
            return view_Boxes.ToList();
        }


    }
}
